package com.qf.spring.test;

import com.qf.spring.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 郑大仙丶
 * @version 1.0
 * @date 2021/3/18 16:35
 * 测试Spring工厂能否帮我创建出User类的对象
 */
public class Demo1 {
    @Test
    public void test(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        // Spring工厂再创建对象时,默认这个对象是单例的.  (饿汉(默认),懒汉)

        // 获取Spring工厂中的对象
        User user1 = (User) context.getBean("user");

        context.close();

    }

}
